package jp.joogoo.web.controller;

import org.slim3.controller.Controller;
import org.slim3.controller.Navigation;

import com.google.appengine.api.users.User;
import com.google.appengine.api.users.UserService;
import com.google.appengine.api.users.UserServiceFactory;

public class IndexController extends Controller {

    @Override
    protected Navigation run() throws Exception {
        UserService userService = UserServiceFactory.getUserService();
        User user = userService.getCurrentUser();

        if (user != null) {
            return redirect("/dashboard");
        } else {
            String art = "/dashboard";
            requestScope("loginUrl", userService.createLoginURL(art));
            return forward("index.jsp");
        }
    }
}
